﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Analysis.SimpleLayer;

namespace Analysis
{
    public partial class frmFaturaDetay : XtraForm
    {
        public int CharID { get; set; }

        public frmFaturaDetay()
        {
            InitializeComponent();
        }

        private void frmFaturaDetay_Load(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("SELECT     st.sto_kod AS [Stok Kodu], st.sto_isim AS [Stok Adı], CAST(fd.sth_miktar AS decimal(16, 4)) AS Miktar,CAST(fd.sth_fiyat AS decimal(16, 4)) AS [Fatura Fiyatı],CAST(fd.fark_tutari / fd.sth_miktar AS decimal(16, 4)) AS [Fiyat Farkı],CAST(fd.fark_tutari AS decimal(16, 4)) AS [Fark Tutarı], DEPOLAR.dep_adi AS Depo \r\n");
            sb.Append(" FROM         FIYAT_FARKI_FATURA_DETAYLARI as fd INNER JOIN STOKLAR as st ON fd.sto_RECno = st.sto_RECno INNER JOIN DEPOLAR ON fd.depo_no = DEPOLAR.dep_no \r\n");
            sb.Append(" WHERE     (fd.cha_RECno = {0}) \r\n");
            dataGrid.DataSource = Factory.GetFactory.ExecuteDataTable(string.Format(sb.ToString(), CharID));
            gridView1.BestFitColumns();
            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                if (gridView1.Columns[i].ColumnType == typeof(double))
                {
                    gridView1.Columns[i].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    gridView1.Columns[i].DisplayFormat.FormatString = "c2";
                }
            }
        }
    }
}
